/**
 * Created by Allen on 2018/1/30.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'

export default {
  // 获取我的代理列表
  /**
   *
   * @param page
   * @param pageSize
   * @param operationCode 1制单 2审批，不传默认为1
   */
  getMyAgencyList(page, pageSize, operationCode){
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/by/proxyOID?operationCode=${operationCode}&page=${page}&searchType=1&size=${pageSize}`)
  },

  //获取我的代理人列表
  /**
   *
   * @param page
   * @param pageSize
   * @param operationCode 1制单 2审批，不传默认为1
   */
  getMyAgentList(page, pageSize, operationCode){
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/by/principalOID?operationCode=${operationCode}&page=${page}&searchType=1&size=${pageSize}`)
  },

  //我的代理人删除接口
  deleteAgent(ruleOID){
    return httpFetch.delete(`${config.baseUrl}/api/billProxyRule/delete/by/ruleOID?ruleOID=${ruleOID}`)
  },

  //获取权限信息
  getProfile(){
    return httpFetch.get(`http://uat.huilianyi.com/api/function/profiles`)
  },

  //报销单、申请单选择项
  getBills(){
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/proxy/forms/search?operationCode=2`)
  },

  //根据姓名／工号查询代理人列表
  getPersonByValue(value, params) {
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/proxy/users/search?keyword=${encodeURIComponent(value)}`, params)
  },

  //代理关系详情保存
  saveAgent(params){
    return httpFetch.post(`${config.baseUrl}/api/billProxyRule`,params)
  },

  //获取可代理的单据 customFormType：1001 申请单 1002 报销单 3001借款单 员工代理审批
  getProxyBills(customFormType) {
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/proxy/forms/audit/search?customFormType=${customFormType}`)
  },

  //获取可代理的单据 customFormType：1001 申请单 1002 报销单 3001借款单 员工代理制单
  getProxyApplyBills(customFormType) {
    return httpFetch.get(`${config.baseUrl}/api/billProxyRule/proxy/forms/search?customFormType=${customFormType}`)
  },
}
